Skip to content

fix(a2a): preserve protocol on card refresh, add custom headers and configurable timeout#3247

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-a2a-configuration-issues
Draft

fix(a2a): preserve protocol on card refresh, add custom headers and configurable timeout#3247
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-a2a-configuration-issues

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown

Three A2A client configuration bugs: protocol selection silently reset on card refresh, no way to set custom HTTP headers per agent, and multi-agent call timeout was hardcoded at 300s with no way to override it.

Protocol preservation on refresh

refresh_agent_card() was re-extracting the protocol from the remote card and overwriting the user's choice. Removed the update_protocol_type branch entirely — protocol is now exclusively mutated via explicit update_agent_protocol().

Custom headers support

  • New custom_headers JSON column on A2AExternalAgent
  • build_a2a_headers(api_key, custom_headers) merges user-supplied headers after base headers, allowing overrides
  • Propagated through a2a_agent_dba2a_client_serviceExternalA2AAgentConfigA2AAgentInfo_build_headers()
  • New PUT /agents/{id}/settings endpoint accepting custom_headers and timeout

Configurable timeout

  • New timeout Float column on A2AExternalAgent (default 300.0)
  • _build_external_agent_config() reads agent.get("timeout") or 300.0 instead of the hardcoded literal
  • SQL migration: v2.2.1_add_custom_headers_timeout_to_external_agent.sql

Frontend

Replaced the narrow AgentProtocolSetting popover with a unified AgentSettings component covering protocol selection, timeout (InputNumber, 1–3600 s), and custom header key-value pairs. i18n keys added for both en and zh locales.

Tests

  • test_a2a_http_client.py: 5 new cases for build_a2a_headers with custom_headers
  • test_a2a_agent_db.py: mock ORM class updated with custom_headers/timeout columns
  • test_a2a_client_service.py: assertion updated to match new build_a2a_headers signature

Copilot AI changed the title [WIP] Fix bugs in A2A configuration and improve stability fix(a2a): preserve protocol on card refresh, add custom headers and configurable timeout Jun 17, 2026
Copilot AI requested a review from Dallas98 June 17, 2026 02:58
status_code=HTTPStatus.BAD_REQUEST,
detail=str(e)
)
except Exception as e:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[代码规范] except Exception: 过于宽泛,建议捕获更具体的异常类型,避免掩盖潜在错误。


class UpdateAgentSettingsRequest(BaseModel):
"""Request to update user-configurable settings for an external A2A agent."""
custom_headers: Optional[dict] = Field(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom_headers 允许用户设置任意 HTTP headers 发送给 A2A agent,但没有验证 header 内容。恶意或有误的用户可能设置 AuthorizationHost 等敏感 header,覆盖系统默认行为或造成安全风险。建议添加 header 名称黑名单(如 Authorization, Host, Content-Type)或白名单验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants